namespace ElectronNET.IntegrationTests.Tests
{
    using System.Runtime.InteropServices;
    using ElectronNET.API;
    using ElectronNET.API.Entities;

    [Collection("ElectronCollection")]
    public class NotificationTests
    {
        [SkippableFact(Timeout = 20000)]
        public async Task Notification_create_check()
        {
            Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Linux), "Always returns false. Might need full-blown desktop environment");

            var tcs = new TaskCompletionSource();

            var options = new NotificationOptions("Notification Title", "Notification test 123");
            options.OnShow = () => tcs.SetResult();

            await Task.Delay(500);

            Electron.Notification.Show(options);

            await Task.WhenAny(tcs.Task, Task.Delay(5_000));

            tcs.Task.IsCompletedSuccessfully.Should().BeTrue();
        }

        [SkippableFact(Timeout = 20000)]
        public async Task Notification_is_supported_check()
        {
            Skip.If(RuntimeInformation.IsOSPlatform(OSPlatform.Linux), "Always returns false. Might need full-blown desktop environment");

            var supported = await Electron.Notification.IsSupportedAsync();
            supported.Should().BeTrue();
        }
    }
}